<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-INF/tlds/messageTag.tld" prefix="msg"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title><msg:message key="menu.install" /></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css" />
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap-switch.css" />
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
	<link rel="StyleSheet" href="${pageContext.request.contextPath}/css/table4jtheme/tabletree4j.css" type="text/css" />
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/layer/skin/espresso/style.css"></link>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/layer/skin/layer.css" id="layui_layer_skinlayercss"/>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/jquery.ui.css"></link>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/css/base.css"></link>
	
	<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.15&key=5c7319868e7c245b3bd8f8b25d81fb20"></script>
	<script src="http://webapi.amap.com/ui/1.0/main.js?v=1.0.11"></script>
	<script src="${pageContext.request.contextPath}/js/jquery-1.12.4.min.js"></script>
	
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/table4j/Core4j.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/table4j/TableTree4j.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-3.1.1.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/tether.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
	<script src="${pageContext.request.contextPath}/js/bootstrap-switch.js"></script>
	
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.ui.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/js/layer/ajaxloading.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/layer/layer.js"></script>

	<style type="text/css">
	
		.bigtitle{
			font-family:Arial;
			font-weight:bold;
			font-size:22px;
			margin-bottom:10px;
		}
		.footer{
			font-family:Arial;
			font-weight:bold;
			font-size:12px;
			color:#747474;
		}
	
		.title{
			padding-left:10px;
			font-family:Arial;
			/*font-weight:bold;*/
			font-size:18px;
			color:#747474;
		}
	
		.fromtitle{
			background-color:#f5f5f5;
			text-align:center;
			font-family:Arial;
			color:#acac59;
			padding-top:5px;
			padding-bottom:5px;
		}
	
		.fromcontent{
			font-family:Arial;
			padding-right:5px;
			padding-bottom:10px;
			padding-top:10px;
		}
	
		.content{
			font-family:Arial;
		}
		.clickbtn{
			cursor:pointer;
		}
		.headerbg{
			background:#328aa4 url(img/tr_back.gif) repeat-x;color:#fff;
			height:27px;
			font-family:"Arial";
		}
		.headerbg td{
			text-align:center;
		}
	
	
		.tabletree4j-gird td{
		height:27px;
		}
	
		.arrow-tt-node-content{
			text-align:center;
			width:100%;
		}
		.circle-tt-node-content{
			text-align:center;
			width:100%;
		}
		.default-tt-node-content{
			text-align:center;
			width:100%;
		}
	</style>
	
	<style type="text/css">
    .textarea {width: 80%; height:80px; padding: 10px; boder:1px solid #ddd; border-radius: 10px; box-shadow: inset 5px 5px 5px #eee;resize:none;}
    .tags {padding: 15px;}
    .tags .tag-link {cursor: pointer; display: inline-block; padding: 5px 10px; margin-right: 10px; border:1px solid #fff;}
    .tags .tag-link:hover {color: #f60;}
    .view {position: relative; padding-left: 80px;}
    .view .view-title {position: absolute; width: 75px; top: 0; left: 0; text-align: right;}

    .moretip-text {white-space: normal; word-break: break-all; word-wrap: break-word; width: 310px; margin-right: 0;}
	</style>
	
	<style type="text/css">
		.jinduBg{
            width: 200px;
            height: 25px;
            margin-right: 40px;
            border: 1px solid grey;
            border-radius: 5px;
            cursor: pointer;
            float:right;
        }
        .jindu{
            width: 50%;
            height: 24px;
            background: 1FA8F1;
            border-radius: 4px;
        }
	</style>
	
	<style>
        #container {
            height: 100%;
            width: 100%;
        }

        .amap-marker:first-child .amap-icon img {
            width: 25px;
            height: 34px;
        }
    </style>
    
    <style type="text/css">
        #tip {
            background-color: #ddf;
            color: #333 !important;
            border: 1px solid silver;
            box-shadow: 3px 4px 3px 0px silver;
            position: absolute;
            top: 25px;
            right: 25px;
            border-radius: 5px;
            overflow: hidden;
            line-height: 20px !important;
            z-index: 999;
        }
        #tip input[type="text"] {
            height: 25px;
            border: 0;
            padding-left: 5px;
            width: 280px;
            border-radius: 3px;
            outline: none;
        }
        
        .amap-sug-result{
			position:absolute;
			z-index:19891016;
			background-color:#fefefe;
			border: 1px solid #d1d1d1;
			bottom:auto;
		}

    </style>
	
	<script language="javascript">
	dummyJsonData = function(){
		this.jsonFIFAHeaders=[{
				  	columns:[
					{dataIndex:'devNum',tdAttributeNames:['width'],tdAttributeValueObject:{width:'18%'}},
					{dataIndex:'addressName',tdAttributeNames:['width'],tdAttributeValueObject:{width:'30%'}},
					{dataIndex:'onlinestate',tdAttributeNames:['width'],tdAttributeValueObject:{width:'10%'}},
					{dataIndex:'stateVal',tdAttributeNames:['width'],tdAttributeValueObject:{width:'10%'}},
					{dataIndex:'operate',tdAttributeNames:['width'],tdAttributeValueObject:{width:'33%'}}
					],
					dataObject:{devNum:'<msg:message key="install.project.code" />',addressName:'<msg:message key="install.project.address" />',onlinestate:'<msg:message key="install.net.status" />',stateVal:'<msg:message key="install.light.status" />',operate:'<msg:message key="install.operation" />'},
					trAttributeNames:['classStyle','style'],
					trAttributeValueObject:{classStyle:'headerbg',style:''}
				  }/*	,
				  	  {
				  	columns:[
						{dataIndex:'title4',
						tdAttributeNames:['colSpan','id'],
						tdAttributeValueObject:{colSpan:2,id:'sdfsdf'}
						},
						{dataIndex:'title5'}
					],
				  	dataObject:{title4:'title4',title5:'title5'},
					trAttributeNames:['classStyle','style'],
					trAttributeValueObject:{classStyle:'headerbg',style:''}
				  }*/
				];
		
		
		this.jsoninitNodes= eval(${jsonTree});
		/* [
				  {id:'group_a',order:1,dataObject:{devNum:'Group A',state:'1'},userObject:{isGroup:true}},
				  {id:'match_1',pid:'group_a',dataObject:{devNum:'South Africa - Mexico',addressName:'11/06 16:00',state:'0'}},
				  {id:'match_34',pid:'group_a',dataObject:{devNum:'France - South Africa',addressName:'22/06 16:00',state:'1'}},
				  {id:'group_b',order:2,isLeaf:false,dataObject:{devNum:'Group B',state:'1'},userObject:{isGroup:true}}
				]; */
	};
	
	//ExpandNodeEvent
	function fifaExpandNodeEvent(node, tree){
		//alert(node.isLoad);
		if (node.isLoad == false) {
			tree.startLoadingNode(node);
			//alert("This alert is show you the node loading...");
	
			//you logic,you can call ajax here , when call success ,use function 'endLoadingNode(node)' to init the loading node;
	
			//example for my dummy data logic
			var userObject=node.userObject;
			if(userObject!=null){
				var jsonName=userObject.jsonName;
				if(jsonName!=null){
					var jsonNodes=eval('new dummyJsonData().'+jsonName);
					if(jsonNodes!=null){
						tree.loadingAddNodes(jsonNodes,node.id);
					}
				}
			}
			/////////////////////////////////
	
			tree.endLoadingNode(node);
		}
	}
	
	function changeLocation(nodeid,obj) {
		var title_text = '<span class="title-h2"><i class="ico-title ico-add"></i>调整位置</span>';         //弹窗标题

		$("#mlat").val('');
    	$("#mlng").val('');
        $("#deviceId").val(nodeid);
        
        $.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/queryLocation.do",
			async: true,
			dataType : "json",
			data : {
				deviceId : nodeid
			},
			success : function(data) {
				if(data.success==0) {
					createMap(data.lat,data.lng);
					
					layer.open({
			            type: 1,
			            area:['800px',''],
			            offset: ['200px', ''],
			            move: false,
			            title: title_text,               //不显示标题
			            content: $('#changeLocationBox'), //捕获的元素
			            cancel: function(index){
			                layer.close(index);
			            },
			            btn:['<msg:message key="btn.confirm" />','<msg:message key="btn.cancel" />'],
			            yes:function(index){ doChangeLocation();},
			            btn2: function(index){
			                layer.closeAll();
			            },
			        });
				}else {
					alert(data.msg);
				}
			}
		});
	}
	
	function createMap(lat,lng) {
		var map = new AMap.Map("container", {
	        resizeEnable: true,
	        center: [lng, lat],
	        zoom: 13,
	        layers:[new AMap.TileLayer.Satellite(),
	                new AMap.TileLayer.RoadNet()
	        ],
	        keyboardEnable: false
	    });
		
		var marker = new AMap.Marker({
	        position: map.getCenter(),
	        icon: '//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
	        offset: new AMap.Pixel(-13, -30),
	        // 设置是否可以拖拽
	        draggable: true,
	        cursor: 'move',
	        // 设置拖拽效果
	        raiseOnDrag: false,
	        zIndex:102
	    });
	    
	    marker.on("dragend", function() {
	    	// 重新获取点坐标
	    	var point = marker.getPosition();
	    	$("#mlat").val(point.lat);
	    	$("#mlng").val(point.lng);
	   	});
	    
	    marker.setMap(map);
	    
		AMap.plugin(['AMap.Autocomplete','AMap.PlaceSearch'],function(){
		      var autoOptions = {
		        //city: "all", //城市，默认全国
		        datatype: "poi",
		        output: "result1",
		        input: "keyword"//使用联想输入的input的id
		      };
		      var autocomplete= new AMap.Autocomplete(autoOptions);
		      var placeSearch = new AMap.PlaceSearch({
		            //city:'北京',
		            map:map,
		            pageSize:1,
		            pageIndex:1,
		            showCover:false,
		            autoFitView:true
		      });
		      AMap.event.addListener(autocomplete, "select", function(e){
		         //TODO 针对选中的poi实现自己的功能
		         placeSearch.setCity(e.poi.adcode);
		         placeSearch.search(e.poi.name,function(status,result){
		        	 if(status!="complete") {
		        		 alert("请输入准确的地址");
		        		 return;
		        	 }
		        	 if(result.poiList.count>0) {
		        	 	$("#mlat").val(result.poiList.pois[0].location.lat);
		    	    	$("#mlng").val(result.poiList.pois[0].location.lng);
		    	    	marker.setPosition(new AMap.LngLat(result.poiList.pois[0].location.lng,result.poiList.pois[0].location.lat,true));
		        	 }else {
		        		 alert("请输入准确的地址");
		        	 }
		         });
		         
		         placeSearch.clear();
	        	 if(placeSearch.render) {
	        		 placeSearch.render.markerList.clear();
	        	 }
		      });
		    });
	}
	
	function doChangeLocation() {
        var nodeid = $("#deviceId").val();
        var mlat = $("#mlat").val();
        var mlng = $("#mlng").val();
        if(mlat=='') {
        	return;
        }
        
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/changeLocation.do",
			async: true,
			dataType : "json",
			data : {
				deviceId : nodeid,
				mlat : mlat,
				mlng : mlng
			},
			success : function(data) {
				if(data.success==0) {
					alert(data.msg);
					layer.closeAll();
					window.location = top.location;
				}else {
					alert(data.msg);
				}
			}
		});
	}
	
	function funcremoveNode(nodeid) {
		if(confirm("<msg:message key='btn.confirmdelete' />")==false) {
			return;
		}
		
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/delDevice.do",
			async: false,
			dataType : "json",
			data : {
				deviceId : nodeid
			},
			success : function(data) {
				alert(data.msg);
				
				if(data.success==0) {
					fifaGirdTree.removeNode(nodeid);
				}
			}
		});
	}
	
	function readDtuStatus(nodeid,obj) {
		var title_text = '<span class="title-h2"><i class="ico-title ico-add"></i><msg:message key='dtu.status.show' /></span>';         //弹窗标题

        var offset_top= $(obj).offset().top;
        var layer_top = (offset_top-100)+'px';
        
        var index = layer.load();
        
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/readDtuStatus.do",
			async: true,
			dataType : "json",
			data : {
				deviceId : nodeid
			},
			success : function(data) {
				if(data.success==0) {
					$("#panIdd").val(data.dtu.panId);
					$("#dtuAddress").val(data.dtu.addressName);
					$("#dtuStatus").val(data.dtuStatus.status);
					$("#dtuTemperture").val(data.dtuStatus.temperature/10.0);
					$("#dtuBatteryVol").val(data.dtuStatus.vol);
					
					layer.close(index);
					
					layer.open({
			            type: 1,
			            // shade: [0.3,'#FFF'],
			            area:['760px',''],
			            offset: ['200px', ''],
			            move: false,
			            title: title_text,               //不显示标题
			            content: $('#dtuStatusBox')
			        });
				}else {
					layer.close(index);
					alert(data.msg);
				}
			}
		});
	}
	
	function readLightStatus(nodeid,obj) {
		var title_text = '<span class="title-h2"><i class="ico-title ico-add"></i>路灯状态</span>';         //弹窗标题

        var offset_top= $(obj).offset().top;
        var layer_top = (offset_top-400)+'px';
        
        var index = layer.load();
		
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/readLightStatus.do",
			async: true,
			dataType : "json",
			data : {
				deviceId : nodeid
			},
			success : function(data) {
				if(data.success==0) {
					$("#lightNum").val(data.light.lightNum);
					$("#lightAddress").val(data.light.addressName);
					$("#lightStatus").val(data.lightStatus.statusType);
					$("#lightTemperature").val(data.lightStatus.temperature);
					
					$("#solarPanelVol").val(data.lightStatus.solarPanelVol);
					$("#lightBatteryVol").val(data.lightStatus.batteryVol);
					$("#chargeCurrent").val(data.lightStatus.chargeCurrent);
					$("#lightWorkCurrent").val(data.lightStatus.workCurrent);
					$("#workVol").val(data.lightStatus.workVol);
					$("#chargeCount").val(data.lightStatus.chargeCount);
					$("#workCount").val(data.lightStatus.workCount);
					$("#temperature").val(data.lightStatus.temperature);
					
					layer.close(index);
					
					layer.open({
			            type: 1,
			            // shade: [0.3,'#FFF'],
			            area:['760px',''],
			            offset: ['30px', ''],
			            move: false,
			            title: title_text,               //不显示标题
			            content: $('#lightStatusBox')
			        });
				}else {
					layer.close(index);
					alert(data.msg);
				}
			}
		});
	}
	
	function modelChange() {
		var controlModelOn = $("#controlModelOn").val();
		var controlModelDown = $("#controlModelDown").val();
		
		if(controlModelOn=="2" && controlModelDown=="2") {
			$("#onVolDiv").css("display","none");
		}else {
			$("#onVolDiv").css("display","block");
		}
		
		if(controlModelOn=="1") {
			$("#timeonDiv").css("display","none");
		}else {
			$("#timeonDiv").css("display","block");
		}
		if(controlModelDown=="1") {
			$("#timedownDiv").css("display","none");
		}else {
			$("#timedownDiv").css("display","block");
		}
		
		if(controlModelOn=="2" && controlModelDown=="1") {
			$("#onVolDivDoc").text("关灯电压：");
		}else {
			$("#onVolDivDoc").text("开灯电压：");
		}
		
	}
	
	function readRtuConfig(nodeid,obj) {
		var title_text = '<span class="title-h2"><i class="ico-title ico-add"></i>当前配置</span>';         //弹窗标题

        var offset_top= $(obj).offset().top;
        var layer_top = (offset_top-500)+'px';
        
        var configFlag = false;
        
        var index = layer.load();
        
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath }/readRtuConfig.do",
			async: true,
			dataType : "json",
			data : {
				deviceId : nodeid
			},
			success : function(data) {
				if(data.success==0) {
					$("#lightNumber").val(data.light.lightNum);
					$("#addressName").val(data.light.addressName);
					
					$("#lightType").val(data.lightConfigBean.lightType);
					$("#serialNum").val(data.lightConfigBean.serialNum);
					
					$("#productTime").val(data.lightConfigBean.productTime);
					$("#controlModelOn").val(data.lightConfigBean.controlModel.substring(0,1));
					$("#controlModelDown").val(data.lightConfigBean.controlModel.substring(1,2));
					$("#turnonVol").val(data.lightConfigBean.turnonVol);
					$("#turnonTime").val(data.lightConfigBean.turnonTime);
					$("#shutdownTime").val(data.lightConfigBean.shutdownTime);
					$("#workModel").val(data.lightConfigBean.workModel);
					modelChange();
					$("#topVol").val(data.lightConfigBean.topVol);
					$("#lowVol").val(data.lightConfigBean.lowVol);
					$("#exitVol").val(data.lightConfigBean.exitVol);
					$("#lowStartVol").val(data.lightConfigBean.lowStartVol);
					$("#lowEndVol").val(data.lightConfigBean.lowEndVol);
					$("#maxWorkCurrent").val(data.lightConfigBean.maxWorkCurrent);
					$("#time1").val(data.lightConfigBean.time1);
					$("#workCurrent1").val(data.lightConfigBean.workCurrent1);
					$("#workCurrent1JD").width(data.lightConfigBean.workCurrent1+'%');
					$("#workCurrent1Val").text(data.lightConfigBean.workCurrent1);
					$("#time2").val(data.lightConfigBean.time2);
					$("#workCurrent2").val(data.lightConfigBean.workCurrent2);
					$("#workCurrent2JD").width(data.lightConfigBean.workCurrent2+'%');
					$("#workCurrent2Val").text(data.lightConfigBean.workCurrent2);
					$("#time3").val(data.lightConfigBean.time3);
					$("#workCurrent3").val(data.lightConfigBean.workCurrent3);
					$("#workCurrent3JD").width(data.lightConfigBean.workCurrent3+'%');
					$("#workCurrent3Val").text(data.lightConfigBean.workCurrent3);
					$("#time4").val(data.lightConfigBean.time4);
					$("#workCurrent4").val(data.lightConfigBean.workCurrent4);
					$("#workCurrent4JD").width(data.lightConfigBean.workCurrent4+'%');
					$("#workCurrent4Val").text(data.lightConfigBean.workCurrent4);
					
					configFlag = true;
					layer.close(index);
					
					layer.open({
			            type: 1,
			            // shade: [0.3,'#FFF'],
			            area:['800px',''],
			            offset: ['30px', ''],
			            move: false,
			            title: title_text,               //不显示标题
			            content: $('#addTemplateLayer')
			        });
				}else {
					layer.close(index);
					alert(data.msg);
				}
			}
		});
	}
	
	function shutdownLight(nodeid,obj) {
		var index = layer.load();
		
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/shutdownLight.do",
			async: true,
			dataType : "json",
			data : {
				deviceId : nodeid
			},
			success : function(data) {
				layer.close(index);
				alert(data.msg);
				
				if(data.success==0) {
					location.href = "${pageContext.request.contextPath}/showDevice.do";
				}else {
					$(obj).bootstrapSwitch('setState', true);
				}
			}
		});
	}
	
	////////////////////////////////////////////////////////////////////////////
	function changeLightId(nodeid,obj) {
		var title_text = '<span class="title-h2"><i class="ico-title ico-add"></i><msg:message key='install.operation.changeid' /></span>';         //弹窗标题

        $("#deviceIdStr").val(nodeid);
		$("#panIdNew").val("");
		$("#lightNumNew").val("");

        layer.open({
            type: 1,
            // shade: [0.3,'#FFF'],
            area:['760px',''],
            offset: ['200px', ''],
            move: false,
            title: title_text,               //不显示标题
            content: $('#changeLightIdBox'), //捕获的元素
            cancel: function(index){
                layer.close(index);
            },
            btn:['<msg:message key="btn.confirm" />','<msg:message key="btn.cancel" />'],
            yes:function(index){ doChangeLightId();},
            btn2: function(index){
                layer.closeAll();
            }
        });
        
	}
	
	function doChangeLightId() {
		var reg = /[0-9|A-E]{4}/;
		var nodeid = $("#deviceIdStr").val();
		if(nodeid==null || nodeid=="") {
			alert("该设备不存在！");
			return;
		}
		
		var panIdNew = $("#panIdNew").val();
		if(panIdNew==null || panIdNew=="") {
			alert("请输入新设备编号！");
			return;
		}
		
		if(reg.test(panIdNew)==false) {
			alert("请输入正确的新设备编号！");
			return;
		}
		
		var lightNumNew = $("#lightNumNew").val();
		if(lightNumNew==null || lightNumNew=="") {
			alert("请输入新路灯编号！");
			return;
		}
		
		if(reg.test(lightNumNew)==false) {
			alert("请输入正确的新路灯编号！");
			return;
		}
		
		var reqsuccess = false;
		
		var index = layer.load();
		
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/changeLightId.do",
			async: true,
			dataType : "json",
			data : {
				deviceId : nodeid,
				panIdNew : panIdNew,
				lightNumNew : lightNumNew
			},
			success : function(data) {
				alert(data.msg);
				
				if(data.success==0) {
					layer.close(index);
					location.href = "${pageContext.request.contextPath}/showDevice.do";
				}else {
					reqsuccess = true;
					layer.close(index);
				}
			}
		});
		
		if(reqsuccess==true) {
			return;
		}
	}
	/////////////////////////////////////////////////////////////////
	var stateflag = true;
	function turnonLight(nodeid,obj) {
		if(stateflag==false) {
			stateflag = true;
			return;
		}
		var title_text = '<span class="title-h2"><i class="ico-title ico-add"></i>开灯设置</span>';         //弹窗标题

        $("#deviceId").val(nodeid);
		$("#minute").val("");
		$("#workCurrent").val("");

        layer.open({
            type: 1,
            // shade: [0.3,'#FFF'],
            area:['760px',''],
            offset: ['200px', ''],
            move: false,
            title: title_text,               //不显示标题
            content: $('#turnonLightBox'), //捕获的元素
            cancel: function(index){
            	/* $(obj).bootstrapSwitch("setState", false); */
            	/* $(obj).bootstrapSwitch('state', true, true); */
            	stateflag = false;
                layer.close(index);
            	$(obj).bootstrapSwitch('toggleState');
            },
            btn:['<msg:message key="btn.confirm" />','<msg:message key="btn.cancel" />'],
            yes:function(index){ doTurnonLight();},
            btn2: function(index){
            	/* $(obj).bootstrapSwitch("setState", true); */
            	/* $(obj).bootstrapSwitch('state', true, true); */
            	stateflag = false;
            	$(obj).bootstrapSwitch('toggleState');
                
                layer.closeAll();
            },
        });
        
	}
	
	function doTurnonLight() {
		var nodeid = $("#deviceId").val();
		if(nodeid==null || nodeid=="") {
			alert("该设备不存在！");
			return;
		}
		
		var workCurrent = $("#workCurrent").val();
		if(workCurrent==null || workCurrent=="") {
			alert("请输入工作电流！");
			return;
		}
		
		var minute = $("#minute").val();
		if(minute==null || minute=="") {
			alert("请输入工作时长！");
			return;
		}
		
		var reqsuccess = false;
		
		var index = layer.load();
		
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/turnonLight.do",
			async: true,
			dataType : "json",
			data : {
				deviceId : nodeid,
				workCurrent : workCurrent,
				minute : minute
			},
			success : function(data) {
				alert(data.msg);
				
				if(data.success==0) {
					layer.close(index);
					location.href = "${pageContext.request.contextPath}/showDevice.do";
				}else {
					reqsuccess = true;
					layer.close(index);
				}
			}
		});
		
		if(reqsuccess==true) {
			return;
		}
	}
	
	function configRtu() {
		var lightId = $("#lightId").val();
		if(lightId==null || lightId=="") {
			alert("该设备不存在！");
			return;
		}
		
		var templateId = $("#templateId").val();
		if(templateId==null || templateId=="") {
			alert("请输选择模板配置！");
			return;
		}
		
		var index = layer.load();
		
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/configRtu.do",
			async: true,
			dataType : "json",
			data : {
				lightId : lightId,
				templateId : templateId
			},
			success : function(data) {
				layer.close(index);
				alert(data.msg);
				if(data.success==0) {
					location.href = "${pageContext.request.contextPath}/showDevice.do";
				}
			}
		});
	}
	
	function addLight() {
		var lightNums = "";
		var longitudes = "";
		var latitudes = "";
		var dtuId = $("#dtuId").val();

		// 校验
		var lightNumArr = document.getElementsByName("lightNum");
		for(var i=0;i<lightNumArr.length;i++) {
			if(lightNumArr[i].checked==true) {
				var lightNum = lightNumArr[i].value;
				lightNums += lightNum + ",";
				var longitude = $("#longitude"+lightNum).val();
				if(longitude==null || longitude=="") {
					alert("请输入经度");
					return;
				}
				
				longitudes += longitude + ",";
				var latitude = $("#latitude"+lightNum).val();
				if(latitude==null || latitude=="") {
					alert("请输入纬度");
					return;
				}
				
				latitudes += latitude + ",";
			}
		}
		
		if(lightNums.length==0) {
			alert("请选择要添加的路灯");
			return;
		}
		
		lightNums = lightNums.substring(0, lightNums.length-1);
		longitudes = longitudes.substring(0, longitudes.length-1);
		latitudes = latitudes.substring(0, latitudes.length-1);
		
		var addLightRes = false;
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/addLight.do",
			async: false,
			dataType : "json",
			data : {
				dtuId : dtuId,
				lightNums : lightNums,
				longitudes : longitudes,
				latitudes : latitudes
			},
			success : function(data) {
				if(data.success==0) {
					alert(data.msg);
					layer.closeAll();
					location.href="${pageContext.request.contextPath}/showDevice.do";
				}else {
					alert(data.msg);
					addLightRes = true;
				}
			}
		});
		
		if(addLightRes==true) {
			return;
		}
	}
	
	function initTemplateData() {
        var html = '';
        
        // 获取LightNum数据
        $.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/queryConfigTemplateList.do",
			async: false,
			dataType : "json",
			success : function(data) {
				if(data.success==0) {
					html = data.templateHtml;
				}else {
					alert("暂时没有配置模板，请先添加配置模板");
				}
			}
		});
        
        if(html == '') {
        	return false;
        }
        
        $('#templateId').html(html);
        
        return true;
    }
	
	function goToAddLight(nodeid,obj) {
         $("#dtuId").val(nodeid);
         var html = '';
         
         var index = layer.load();
         
         // 获取LightNum数据
         $.ajax({
 			type : "POST",
 			url : "${pageContext.request.contextPath}/beforeAddLight.do",
 			async: true,
 			dataType : "json",
 			data : {
 				deviceId : nodeid
 			},
 			success : function(data) {
 				if(data.success==0) {
 					for(var k=0;k<data.resultdata.length;k++) {
 			            html +='<tr data-id="1">';
 			                html +='<td class="td-check"><input type="checkbox" name="lightNum" value="'+data.resultdata[k]['lightNum']+'"><input type="hidden" name="lightNumAll" value="'+data.resultdata[k]['lightNum']+'"></td>';
 			                html +='<td class="td-text">'+data.resultdata[k]['lightNum']+'</td>';
 			                html +='<td width="50px" class="td-text"><span>经度:</span></td><td stype="border-bottom:1px;"><input type="text" id="longitude'+data.resultdata[k]['lightNum']+'" name="longitude"/></td>';
 			                html +='<td width="50px" class="td-text"><span>纬度:</span></td><td><input type="text" id="latitude'+data.resultdata[k]['lightNum']+'" name="latitude"/></td>';
 			            html +='</tr>';
 			        }
 					
 					if(html != '') {
 			        	$('#layerWithTbody').html(html);
 			        	layer.close(index);
 			        	showAddLightWindow();
 			        }
 				}else {
 					layer.close(index);
 					alert("该DTU下暂时未发现新RTU");
 				}
 			}
 		});
	}
	
	function showAddLightWindow() {
		var title_text = '<span class="title-h2"><i class="ico-title ico-add"></i>添加RTU</span>';         //弹窗标题
        var offset_top= $(obj).offset().top;
        var layer_top = (offset_top+100)+'px';
        
    	layer.open({
            skin: 'layer-ext-espresso',
            type: 1,
            // shade: [0.3,'#FFF'],
            area:['760px',''],
            offset: ['200px', ''],
            move: false,
            title: title_text,               //不显示标题
            content: $('#addLightBox'), //捕获的元素
            cancel: function(index){
                layer.close(index);
            },
            btn:['<msg:message key="btn.confirm" />','<msg:message key="btn.cancel" />'],
            yes:function(){ addLight();},
            cancel:function(){  layer.closeAll(); }
        });
	}
	
	function goToConfigRtu(nodeid,obj) {
        var title_text = '<span class="title-h2"><i class="ico-title ico-add"></i>根据模板配置RTU</span>';         //弹窗标题

        var offset_top= $(obj).offset().top;
        var layer_top = (offset_top+100)+'px';
        
        $("#lightId").val(nodeid);
        if(initTemplateData()==false) {
       	return; 
        }

        layer.open({
            type: 1,
            // shade: [0.3,'#FFF'],
            area:['760px',''],
            offset: ['200px', ''],
            move: false,
            title: title_text,               //不显示标题
            content: $('#configRtuBox'), //捕获的元素
            cancel: function(index){
                layer.close(index);
            },
            btn:['<msg:message key="btn.confirm" />','<msg:message key="btn.cancel" />'],
            yes:function(){ configRtu();},
            cancel:function(){  layer.closeAll(); }
        });
	}
	
	//infoObj {dataValue:,node:,tabletreeObj:,rowObj:,rowIndex:,container:,columnIndex:}
	function operateRenderFunction(infoObj){
		//var value=infoObj.dataValue;
		var node=infoObj.node;
		//var tree=infoObj.tabletreeObj;
		var htmlobj = "<input class=\"btn btn-danger\" type=\"button\" onclick=\"funcremoveNode('"+node.id+"');\" value=\"<msg:message key='install.operation.delete' />\" /> ";
		if(node.dataObject.dtuType=='1') {
			if(node.dataObject.state==1) {
				// htmlobj += "  <input type=\"button\" onclick=\"shutdownLight('"+node.id+"');\" value=\"关灯\"/>";
				htmlobj += "<input type=\"checkbox\" name=\"my-checkbox\" checked data-off-color=\"warning\" onchange=\"shutdownLight('"+node.id+"',this);\" />";
			}else {
				// htmlobj += "  <input type=\"button\" onclick=\"turnonLight('"+node.id+"',this);\" value=\"开灯\" />";
				htmlobj += "<input type=\"checkbox\" name=\"my-checkbox\" data-off-color=\"warning\" onchange=\"turnonLight('"+node.id+"',this);\" />";
			}
			return htmlobj;
		}
		
		if(node.isLeaf==false) {
			htmlobj += "<input class=\"btn btn-primary\" type=\"button\" onclick=\"goToAddLight('"+node.id+"',this);\" value=\"<msg:message key='install.operation.addlight' />\" /> ";
			htmlobj += "<input class=\"btn btn-secondary\" type=\"button\" onclick=\"readDtuStatus('"+node.id+"',this);\" value=\"<msg:message key='install.operation.viewstatus' />\" /> ";
		}else {
			htmlobj += "<input class=\"btn btn-secondary\" type=\"button\" onclick=\"readLightStatus('"+node.id+"',this);\" value=\"<msg:message key='install.operation.viewstatus' />\" /> ";
			htmlobj += "<input class=\"btn btn-secondary\" type=\"button\" onclick=\"readRtuConfig('"+node.id+"',this);\" value=\"<msg:message key='install.operation.viewconfig' />\" /> ";
			htmlobj += "<input class=\"btn btn-info\" type=\"button\" onclick=\"goToConfigRtu('"+node.id+"',this);\" value=\"<msg:message key='install.operation.configrtu' />\" /> ";
			<c:if test="${isAdmin eq true}">
				htmlobj += "<input class=\"btn btn-info\" type=\"button\" onclick=\"changeLightId('"+node.id+"',this);\" value=\"<msg:message key='install.operation.changeid' />\" /> ";
			</c:if>
		}
		
		htmlobj += "<input class=\"btn btn-info\" type=\"button\" onclick=\"changeLocation('"+node.id+"',this);\" value=\"<msg:message key='install.operation.changelocation' />\" /> ";
		
		if(node.dataObject.state==1) {
			// htmlobj += "  <input type=\"button\" onclick=\"shutdownLight('"+node.id+"');\" value=\"关灯\"/>";
			htmlobj += "<input type=\"checkbox\" name=\"my-checkbox\" checked data-off-color=\"warning\" onchange=\"shutdownLight('"+node.id+"',this);\" />";
		}else {
			// htmlobj += "  <input type=\"button\" onclick=\"turnonLight('"+node.id+"',this);\" value=\"开灯\" />";
			htmlobj += "<input type=\"checkbox\" name=\"my-checkbox\" data-off-color=\"warning\" onchange=\"turnonLight('"+node.id+"',this);\" />";
		}
		
		return htmlobj;
	}
	
	///////////////////////////////////////////////////////////
	
	//the flow of build tabletree
	
	//create and config tabletree object
	var fifaGirdTree=new Core4j.toolbox.TableTree4j({
		columns:[
				{isNodeClick:true,dataIndex:'devNum'},
				{dataIndex:'addressName',renderFunction:null},
				{dataIndex:'onlinestate',mystyle:'text-align:center'},
				{dataIndex:'stateVal',mystyle:'text-align:center'},
				{dataIndex:'operate',canSort:false,renderFunction:operateRenderFunction}
				],
		treeMode:'gird',
		renderTo:'worldcupgird',
		useLine:true,
		useIcon:true,
		id:'myworldcupgirdtree',
		useCookie:false,
		onExpandNodeEvents:[fifaExpandNodeEvent],
		headers:new dummyJsonData().jsonFIFAHeaders,
		//footers:jsonfooters,
		themeName:'arrow',
		selectMode:'single',
		scriptRootPath:'${pageContext.request.contextPath}/js/table4j/',
		useOrder:false
		//floatRight:true
	});
	
	//build tree by nodes
	$(document).ready(function(){

		fifaGirdTree.build(new dummyJsonData().jsoninitNodes,true); 
		
		// 实例化switch按钮
		$("[name='my-checkbox']").bootstrapSwitch();
		
		// 添加DTU
        $(document).on('click','#add_dtu_btn',function(){
            var title_text = '<span class="title-h2"><i class="ico-title ico-add"></i><msg:message key="install.addproject" /></span>';         //弹窗标题

            var offset_top= $(this).offset().top;
            var layer_top = (offset_top+100)+'px';
            
            $("#dtuName").val("");
            $("#panId").val("");
			$("#longitude").val("");
			$("#latitude").val("");

            layer.open({
                type: 1,
                // shade: [0.3,'#FFF'],
                area:['760px',''],
                offset: [layer_top, ''],
                move: false,
                title: title_text,               //不显示标题
                content: $('#addDtuBox'), //捕获的元素
                cancel: function(index){
                    layer.close(index);
                },
                btn:['<msg:message key="btn.confirm" />','<msg:message key="btn.cancel" />'],
                yes:function(index){ addDtu();}
            });
        });
     	
	});
	////////////////////////////////////////////////////////////////
	
	function getnodes(){
		alert(fifaGirdTree.nodesMap.length);
		alert(fifaGirdTree.getNodeById('group_d').childs.length);
	}
	
	function sortTree(index){
		if(index==null){
			fifaGirdTree.getNodeById();
		}else{
			fifaGirdTree.sortByColumnIndex(index);
		}
	}
	
	function changeStyle(theme){
		fifaGirdTree.changeTheme(theme);
	}
	
	function addGroup(){
			var gid=document.getElementById("gid").value;
				if(gid!=null&&gid!=''){
					var addnode=fifaGirdTree.getNodeById(gid);
					if(addnode==null){
						var gname=document.getElementById("gname").value;
						var gorder=document.getElementById("gorder").value;
						gorder=parseInt(gorder);
						if(gname==null||gname==''){
							alert("The name of group is required!");
							return null;
						}
						if(isNaN(gorder)){
							gorder=0;
						}
						//{id:'group_b',order:2,isLeaf:false,dataObject:{match:'Group B'},userObject:{isGroup:true,jsonName:'jsonNodes_B'}},
						addnode=new Core4j.toolbox.TableTreeNode({
							id:gid,
							order:gorder,
							isLeaf:false,
							isLoad:true,
							dataObject:{match:gname},
							userObject:{isGroup:true}
						});
						//add one node
						fifaGirdTree.addNode(addnode);
					}else{
						alert("The id of group is exist!");
					}
				}else{
					alert("The id of group is required!");
				}
	}
	function addMatch(){
		var sllectNodes=fifaGirdTree.getSelectNodes();
		var alertMsg="Please select a group.";
		if(sllectNodes==null||sllectNodes.length==0){
			alert(alertMsg);
		}else{
			var pnode=sllectNodes[0];
			if(pnode.userObject!=null&&pnode.userObject.isGroup==true){
				var mid=document.getElementById("mid").value;
				if(mid!=null&&mid!=''){
					var addnode=fifaGirdTree.getNodeById(mid);
					if(addnode==null){
						var mteam=document.getElementById("mteam").value||'';
						var mdate=document.getElementById("mdate").value||'';
						var mvenue=document.getElementById("mvenue").value||'';
						var mres=document.getElementById("mres").value||'';
						//{id:'match_3',pid:'group_b',dataObject:{match:'Argentina - Nigeria',datetime:'12/06 16:00',result:'Live',venue:'Johannesburg - JEP'}}
						addnode=new Core4j.toolbox.TableTreeNode({
							id:mid,
							dataObject:{match:mteam,datetime:mdate,result:mres,venue:mvenue}
						});
						//add one node
						fifaGirdTree.addNode(addnode,pnode.id);
					}else{
						alert("The id of match is exist!");
					}
				}else{
					alert("The id of match is required!");
				}
			}else{
				alert(alertMsg);
			}
		}
	}
	/*
	function setunload(){
		var sllectNodes=fifaGirdTree.getSelectNodes();
		var alertMsg="Please select a node."
		if(sllectNodes==null||sllectNodes.length==0){
			alert(alertMsg);
		}else{
			var node=sllectNodes[0];
			fifaGirdTree.setNodeAsUnload(node.id);
		}
	}
	*/
	
	function addDtu() {
		var dtuName = $("#dtuName").val();
		if(dtuName=="") {
			alert("<msg:message key='dtu.add.msg.projectname.empty' />");
			return;
		}
		
		var panId = $("#panId").val();
		if(panId=="") {
			alert("<msg:message key='dtu.add.msg.projectcode.emtpy' />");
			return;
		}
		
		var longitude = $("#longitude").val();
		if(longitude=="") {
			alert("<msg:message key='dtu.add.msg.lng.emtpy' />");
			return;
		}
		var latitude = $("#latitude").val();
		if(latitude=="") {
			alert("<msg:message key='dtu.add.msg.lat.emtpy' />");
			return;
		}
		
		var dtuType = $("#dtuType").val();
		
		var addDtuRes = false;
		
		$.ajax({
			type : "POST",
			url : "${pageContext.request.contextPath}/addDtu.do",
			async: false,
			dataType : "json",
			data : {
				dtuName : dtuName,
				panId : panId,
				longitude : longitude,
				latitude : latitude,
				dtuType : dtuType
			},
			success : function(data) {
				if(data.success==0) {
					alert(data.msg);
					layer.closeAll();
					location.href="${pageContext.request.contextPath}/showDevice.do";
				}else {
					alert(data.msg);
					addDtuRes = true;
				}
			}
		});
		
		if(addDtuRes==true) {
			return;
		}
	}
	</script>
  </head>
  
  <body>
  <div class="header">
		<div class="left header-logo"><img class="header-logo-img" src="images/header_logo.png" /></div>
		<div class="right header-nav">
			<a class="nav-link" href="${pageContext.request.contextPath }/main.do">
				<i class="icon icon-home"></i>
				<span class="link-text"><msg:message key="menu.homepage" /></span>
			</a>
			<c:if test="${menubean.menu1 }">
			<a class="nav-link active" href="${pageContext.request.contextPath }/showDevice.do">
				<i class="icon icon-install"></i>
				<span class="link-text"><msg:message key="menu.install" /></span>
			</a>
			</c:if>
			<c:if test="${menubean.menu2 }">
			<a class="nav-link" href="${pageContext.request.contextPath}/showConfig.do">
				<i class="icon icon-config"></i>
				<span class="link-text"><msg:message key="menu.config" /></span>
			</a>
			</c:if>
			<c:if test="${menubean.menu3 }">
			<!-- <a class="nav-link" href="operation.html">
				<i class="icon icon-operation"></i>
				<span class="link-text">操作</span>
			</a> -->
			<a class="nav-link" href="${pageContext.request.contextPath}/dataNew.do">
				<i class="icon icon-data"></i>
				<span class="link-text"><msg:message key="menu.data" /></span>
			</a>
			</c:if>
			<%-- <c:if test="${menubean.menu4 }">
			<a class="nav-link" href="history.html">
				<i class="icon icon-history"></i>
				<span class="link-text">历史</span>
			</a>
			</c:if> --%>
			<c:if test="${menubean.menu4 }">
			<a class="nav-link" href="${pageContext.request.contextPath}/faultList.do">
				<i class="icon icon-malfunction"></i>
				<span class="link-text"><msg:message key="menu.error" /></span>
			</a>
			</c:if>
			<c:if test="${menubean.menu5 }">
			<a class="nav-link" href="${pageContext.request.contextPath}/showUserList.do">
				<i class="icon icon-customer-management"></i>
				<span class="link-text"><msg:message key="menu.user" /></span>
			</a>
			</c:if>
			<c:if test="${menubean.menu6 }">
			<a class="nav-link" href="${pageContext.request.contextPath}/statusList.do">
				<i class="icon icon-status"></i>
				<span class="link-text"><msg:message key="menu.status" /></span>
			</a>
			</c:if>
			<c:if test="${menubean.menu7 }">
			<a class="nav-link" href="${pageContext.request.contextPath}/currentList.do">
				<i class="icon icon-malfunction"></i>
				<span class="link-text"><msg:message key="menu.current" /></span>
			</a>
			</c:if>
			<c:if test="${menubean.menu8 }">
			<a class="nav-link" href="${pageContext.request.contextPath}/report.do">
				<i class="icon icon-history"></i>
				<span class="link-text"><msg:message key="menu.report" /></span>
			</a>
			</c:if>
			<a class="nav-link" href="${pageContext.request.contextPath}/logout.do">
				<i class="icon icon-out"></i>
				<span class="link-text"><msg:message key="menu.exit" /></span>
			</a>
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>
	
	<div class="section">
		<div class="page-mainbox">
			<div>
		   		<input type="button" id="add_dtu_btn" class="add-dtu-btn" value="" />
			</div>
			<div class="block20"></div>
		   	<div id="worldcupgird" class="content"></div>
	   	</div>
   	</div>
   	
   	<div id="addDtuBox" class="fahuo-layer-div" style="display:none;">
		<div class="form-div">
			<form id="form2"
				action="${pageContext.request.contextPath }/addDtu.do"
				method="post">
				<div class="view view160">
		            <span class="view-title"><msg:message key='install.project.name' />：</span>
		            <input id="dtuName" name="dtuName" title="dtuName" class="hw_input3" maxlength="20" type="text" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
				<div class="view view160">
		            <span class="view-title"><msg:message key='install.project.code' />：</span>
		            <input id="panId" name="panId" title="PanId" class="hw_input3" maxlength="20" type="text" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
				<div class="view view160">
		            <span class="view-title"><msg:message key='install.longitude' />：</span>
		            <input id="longitude" name="longitude" title="<msg:message key='install.longitude' />" class="hw_input3" maxlength="50" type="text" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='install.latitude' />：</span>
		            <input id="latitude" name="latitude" title="<msg:message key='install.latitude' />" class="hw_input3" maxlength="50" type="text" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='install.device.type' />：</span>
		            <select id="dtuType" name="dtuType" class="hw_input3">
		            	<option value="0"><msg:message key='install.device.type.dtu' /></option>
		            	<option value="1"><msg:message key='install.device.type.group' /></option>
		            </select>
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
			</form>
		</div>
	</div>
		
		<div id="addLightBox" class="fahuo-layer-div" style="display:none;">
			<div class="form-div">
				<form id="form3"
					action="${pageContext.request.contextPath }/addLight.do"
					method="post">
					<input type="hidden" id="dtuId" name="dtuId" value="" />
					<div class="show-list">
		              <table>
		                  <tbody id="layerWithTbody">
		                  </tbody>
		              </table>
		            </div>
				</form>
			</div>
		</div>
		
		<div id="turnonLightBox" class="fahuo-layer-div" style="display:none;">
			<div class="form-div">
            	<input id="deviceId" name="deviceId" type="hidden" />
				<div class="view view160">
		            <span class="view-title">负载功率（%）：</span>
		            <input id="workCurrent" name="workCurrent" title="工作电流" class="hw_input3" maxlength="50" type="text" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title">工作时长（分钟）：</span>
		            <input id="minute" name="minute" title="工作时常" class="hw_input3" maxlength="50" type="text" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
			</div>
		</div>
		
		<div id="changeLightIdBox" class="fahuo-layer-div" style="display:none;">
			<div class="form-div">
            	<input id="deviceIdStr" name="deviceIdStr" type="hidden" />
				<div class="view view160">
		            <span class="view-title">设备编号：</span>
		            <input id="panIdNew" name="panIdNew" title="设备编号" class="hw_input3" maxlength="50" type="text" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title">路灯编号：</span>
		            <input id="lightNumNew" name="lightNumNew" title="路灯编号" class="hw_input3" maxlength="50" type="text" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
			</div>
		</div>
		
		<div id="configRtuBox" class="fahuo-layer-div" style="display:none;">
			<div class="form-div">
            	<input id="lightId" name="lightId" type="hidden" />
				<div class="view view160">
		            <span class="view-title">配置模板：</span>
		            <select class="hw_input3" name="templateId" id="templateId">
		            </select>
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
			</div>
		</div>
		
		<div id="dtuStatusBox" class="fahuo-layer-div" style="display:none;">
			<div class="form-div">
				<div class="view view160">
		            <span class="view-title"><msg:message key='dtu.code' />：</span>
		            <input id="panIdd" name="panIdd" class="hw_input3"  type="text" readonly="readonly"/>
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='dtu.addr' />：</span>
		            <input id="dtuAddress" name="dtuAddress" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='dtu.status' />：</span>
		            <input id="dtuStatus" name="dtuStatus" class="hw_input3" maxlength="50" type="text"  readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='dtu.temperature' />：</span>
		            <input id="dtuTemperture" name="dtuTemperture" class="hw_input3" maxlength="50" type="text"  readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='dtu.battery.voltage' />：</span>
		            <input id="dtuBatteryVol" name="dtuBatteryVol" class="hw_input3" maxlength="50" type="text"  readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
			</div>
		</div>
		
		<div id="lightStatusBox" class="fahuo-layer-div" style="display:none;">
			<div class="form-div">
				<div class="view view160">
		            <span class="view-title"><msg:message key='light.code' />：</span>
		            <input id="lightNum" name="lightNum" class="hw_input3"  type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.addr' />：</span>
		            <input id="lightAddress" name="lightAddress" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.status.title' />：</span>
		            <input id="lightStatus" name="lightStatus" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.status.temperature' />：</span>
		            <input id="lightTemperature" name="lightTemperature" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.status.solarpanelvol' />：</span>
		            <input id="solarPanelVol" name="solarPanelVol" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.status.batteryvol' />：</span>
		            <input id="lightBatteryVol" name="lightBatteryVol" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.status.chargecurrent' />：</span>
		            <input id="chargeCurrent" name="chargeCurrent" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.status.workcurrent' />：</span>
		            <input id="lightWorkCurrent" name="lightWorkCurrent" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.status.workvol' />：</span>
		            <input id="workVol" name="workVol" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.status.chargecount' />：</span>
		            <input id="chargeCount" name="chargeCount" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
		        <div class="block15"></div>
		        <div class="view view160">
		            <span class="view-title"><msg:message key='light.status.workcount' />：</span>
		            <input id="workCount" name="workCount" class="hw_input3" type="text" readonly="readonly" />
		            <i class="ico-must">*</i>
		        </div>
			</div>
		</div>
		
		<div id="addTemplateLayer" style="display:none;">
			<div class="form-div padding20" style="margin-right:20px;">
				<form id="addTemplateForm" method="post">
					<div class="view view160">
			            <span class="view-title"><msg:message key='light.code' />：</span>
			            <input id="lightNumber" name="lightNumber" class="hw_input3" maxlength="50" type="text" readonly="readonly" />
			            <i class="ico-must">*</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='light.addr' />：</span>
			            <input id="addressName" name="addressName" class="hw_input3" maxlength="50" type="text" readonly="readonly" />
			            <i class="ico-must">*</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='light.lighttype' />：</span>
			            <input id="lightType" name="lightType" class="hw_input3" maxlength="50" type="text" readonly="readonly" />
			            <i class="ico-must">*</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='light.serialnum' />：</span>
			            <input id="serialNum" name="serialNum" class="hw_input3" maxlength="50" type="text" readonly="readonly" />
			            <i class="ico-must">*</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='light.producttime' />：</span>
			            <input id="productTime" name="productTime" class="hw_input3" maxlength="50" type="text" readonly="readonly" />
			            <i class="ico-must">*</i>
			        </div>
			        <div class="block15"></div>
					<div class="view view160">
			            <span class="view-title"><msg:message key='config.controlmode' />：</span>
			            <select id="controlModelOn" name="controlModelOn" onchange="modelChange()" class="hw_input5" disabled="disabled">
			            	<option value="1">光控开灯</option>
			            	<option value="2">时控开灯</option>
			            </select>
			            <select id="controlModelDown" name="controlModelDown" onchange="modelChange()" class="hw_input5" disabled="disabled">
			            	<option value="1">光控关灯</option>
			            	<option value="2">时控关灯</option>
			            </select>
			            <i class="ico-must">*</i>
			            <span ><msg:message key='config.workmode' />：</span>
			            <select id="workModel" name="workModel" class="hw_input6" disabled="disabled">
			            	<option value="01">智能</option>
			            	<option value="00">非智能</option>
			            </select>
			            <i class="ico-must">*</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			        	<div id="onVolDiv" style="margin-right:20px;float:left;">
				            <span id="onVolDivDoc"><msg:message key='config.lighton.vol' />：</span>
				            <input id="turnonVol" name="turnonVol" class="hw_input5" maxlength="50" type="text" readonly="readonly"/>
				            <i class="ico-must-red">* (V)</i>
			            </div>
			            <div id="timeonDiv" style="margin-right:20px;float:left;display:none;">
				            <span>开灯时间：</span>
				            <input id="turnonTime" name="turnonTime" class="hw_input5" maxlength="50" type="text" readonly="readonly"/>
				            <i class="ico-must-red">*</i>
				        </div>
				        <div id="timedownDiv" style="float:left;display:none;">
				            <span>关灯时间：</span>
				            <input id="shutdownTime" name="shutdownTime" class="hw_input5" maxlength="50" type="text" readonly="readonly"/>
				            <i class="ico-must-red">*</i>
				        </div>
			        </div>
			       	<div class="block15"></div>
			        <div class="view view160">
			        	<span class="view-title"><msg:message key='config.overcurrent' />：</span>
			            <input id="maxWorkCurrent" name="maxWorkCurrent" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must-red">* (mA)</i>
			            <span style="margin-left:52px;"><msg:message key='config.topprotect' />：</span>
			            <input id="topVol" name="topVol" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must">* (V)</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='config.lowprotect' />：</span>
			            <input id="lowVol" name="lowVol" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must-red">* (V)</i>
			            <span style="margin-left:66px;"><msg:message key='config.exitprotect' />：</span>
			            <input id="exitVol" name="exitVol" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must">* (V)</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='config.lowstartvol' />：</span>
			            <input id="lowStartVol" name="lowStartVol" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must-red">* (V)</i>
			            <span style="margin-left:25px;"><msg:message key='config.lowendvol' />：</span>
			            <input id="lowEndVol" name="lowEndVol" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must">* (V)</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='config.first.period' />：</span>
			            <input id="time1" name="time1" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must-red">* (<msg:message key='config.period.unit' />)</i>
			            <span><msg:message key='config.first.workingpower' />：</span>
			            <div class="jinduBg"  id="workCurrent1JDBG">
						    <div class="jindu" id="workCurrent1JD"></div>
						</div>
						<input id="workCurrent1" name="workCurrent1" class="hw_input6" maxlength="50" value="50" type="hidden"/>
			            <i class="ico-must">* (<span id="workCurrent1Val">50</span>%)</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='config.second.period' />：</span>
			            <input id="time2" name="time2" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must-red">* (<msg:message key='config.period.unit' />)</i>
			            <span><msg:message key='config.second.workingpower' />：</span>
			            <div class="jinduBg"  id="workCurrent2JDBG">
						    <div class="jindu" id="workCurrent2JD"></div>
						</div>
			            <input id="workCurrent2" name="workCurrent2" class="hw_input6" maxlength="50" value="50" type="hidden" />
			            <i class="ico-must">* (<span id="workCurrent2Val">50</span>%)</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='config.third.period' />：</span>
			            <input id="time3" name="time3" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must-red">* (<msg:message key='config.period.unit' />)</i>
			            <span><msg:message key='config.third.workingpower' />：</span>
			            <div class="jinduBg"  id="workCurrent3JDBG">
						    <div class="jindu" id="workCurrent3JD"></div>
						</div>
			            <input id="workCurrent3" name="workCurrent3" class="hw_input6" maxlength="50" value="50" type="hidden" />
			            <i class="ico-must">* (<span id="workCurrent3Val">50</span>%)</i>
			        </div>
			        <div class="block15"></div>
			        <div class="view view160">
			            <span class="view-title"><msg:message key='config.fourth.period' />：</span>
			            <input id="time4" name="time4" class="hw_input6" maxlength="50" type="text" readonly="readonly"/>
			            <i class="ico-must-red">* (<msg:message key='config.period.unit' />)</i>
			            <span><msg:message key='config.fourth.workingpower' />：</span>
			            <div class="jinduBg"  id="workCurrent4JDBG">
						    <div class="jindu" id="workCurrent4JD"></div>
						</div>
			            <input id="workCurrent4" name="workCurrent4" class="hw_input6" maxlength="50" value="50" type="hidden" />
			            <i class="ico-must">* (<span id="workCurrent4Val">50</span>%)</i>
			        </div>
<!-- 					<div class="layui-layer-btn">
						<a class="layui-layer-btn0" onclick="submitAdd();">确定</a>
						<a class="layui-layer-btn0" onclick="defaultConfig();">默认配置</a>
						<a class="layui-layer-btn1">取消</a>
					</div> -->
					<input class="hide" type="reset" name="resetBtn">
				</form>
			</div>
		</div>
		
		<div id="changeLocationBox" class="fahuo-layer-div" style="display:none;">
			<div class="form-div">
				<div id="tip">
				    <input type="text" id="keyword" name="keyword" value="请输入关键字：(选定后搜索)" onfocus='this.value=""'/>
				</div>
            	<input id="mdeviceId" name="mdeviceId" type="hidden" />
            	<input id="mlat" name="mlat" type="hidden" />
            	<input id="mlng" name="mlng" type="hidden" />
            	<div id="container" style="width:760px;height:500px;z-index:10;"></div>
			</div>
		</div>
  </body>
</html>
